package com.zryc.shop.oms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zryc.shop.oms.entity.Order;
import com.zryc.shop.oms.mapper.OrderItemMapper;
import com.zryc.shop.oms.mapper.OrderMapper;
import com.zryc.shop.oms.mapper.OrderOperateHistoryMapper;
import com.zryc.shop.oms.service.IOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author LiYe
 * @since 2023-02-14
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
    @Autowired
    private OrderItemMapper orderItemMapper;
    @Autowired
    private OrderOperateHistoryMapper orderOperateHistoryMapper;
    @Override
    public Order getById(Serializable id) {
        Order order = super.getById(id);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("order_id", id);
        order.setOrderItemList(orderItemMapper.selectList(queryWrapper));
        order.setHistoryList(orderOperateHistoryMapper.selectList(queryWrapper));
        return order;
    }
}
